﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mimoza.Apps.Service
{
    /// <summary>
    /// Application class is a core of application.
    /// </summary>
    class Application
    {
        public Application(ServiceLayer.Configuration config)
        {
            m_config = config;
        }

        ServiceLayer.Configuration Configuration
        {
            get { return m_config; }
        }

        public void Init()
        {
            m_bStopFlag = false;

            Configuration.Build();
            Configuration.DatabaseConnect();
            Configuration.CreateListener();
        }

        public void Stop()
        {
            m_bStopFlag = true;

            Configuration.Deinit();
        }

        public void DoWork()
        {
            while (!m_bStopFlag)
            {
                Transport.Transport.Dispatcher.DoProcess();
            }
        }

        ServiceLayer.Configuration m_config = null;
        bool m_bStopFlag = false;
    }
}
